package com.xbongbong.saas.model;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.saas.domain.entity.BomUserEntity;
import com.xbongbong.saas.domain.entity.UserTeamEntity;
import org.elasticsearch.action.support.WriteRequest;

import java.util.List;
import java.util.Map;

/**
 * @author long.rao
 * @version v1.0
 * @date 2019/2/1 14:30
 * @since v1.0
 */
public interface BomUserModel extends IModel<BomUserEntity> {
    /**
     * BOM单协同团队数据插入
     *
     * @param entity BOM单协同团队实体
     * @throws XbbException 异常
     * @return Integer
     * @author long.rao
     * @date 2019-02-01 15:24
     */
    @Override
    Integer insert(BomUserEntity entity) throws XbbException;
    /**
     * BOM单协同团队数据更新
     *
     * @param entity BOM单协同团队实体
     * @author long.rao
     * @date 2019-02-01 15:24
     * @throws XbbException 异常
     * @return Integer
     */

    @Override
    Integer update(BomUserEntity entity) throws XbbException;
    /**
     * BOM单协同团队数据查询多个
     *
     * @param param 参数
     * @author long.rao
     * @date 2019-02-01 15:24
     * @return List<BomUserEntity>
     */
    @Override
    List<BomUserEntity> findEntitys(Map<String, Object> param);
    /**
     * BOM单协同团队数据查询条数
     * @param param 参数
     * @author long.rao
     * @date 2019-02-01 15:24
     * @return Integer
     */
    @Override
    Integer getEntitysCount(Map<String, Object> param);
    /**
     * BOM单协同团队数据单条查询
     * @param key 主键ID
     * @param corpid 公司ID
     * @author long.rao
     * @date 2019-02-01 15:24
     * @return Integer
     */
    BomUserEntity getByKey(Long key, String corpid);
    /**
     * 保存实体
     *
     * @param bomUserEntity Bom协同人团队实体
     * @return java.lang.Integer
     * @throws XbbException 数据库异常
     * @author long.rao
     * @date 2019-02-17 16:47
     */
    Integer save(BomUserEntity bomUserEntity) throws XbbException;

    /**
     * 批量删除bom单的负责人
     * @author 吴峰
     * @date 2019/3/6 21:26
     * @param list bom单id列表
     * @param corpid 公司id
     * @return java.lang.Integer
     * @throws XbbException 业务异常
     */
    Integer deleteByBomIdIn(List<Long> list, String corpid) throws XbbException;

    /**
     * 查询协同团队基础列表
     * @param map 参数
     * @return 团队
     */
    List<UserTeamEntity> findBaseEntitys(Map<String,Object> map);

    /**
     * 获取协同团队的业务数据
     * @param corpid 公司id
     * @param isMain 负责或协同
     * @param userId 用户id
     * @return List<Long>
     */
    List<Long> getDataIdList(String corpid, Integer isMain, List<String> userId);

    /**
     * 删除
     *
     * @param  bomUserEntity 删除的数据
     * @author GuoJun.HU 
     * @since V1.0
     * @date 2019/4/19 15:47
     */
    void delete(BomUserEntity bomUserEntity) throws XbbException;

    /**
     * 通过Bom的id获取团队
     *
     * @param corpid        公司id
     * @param bomId         BomId
     * @author GuoJun.HU
     * @since V1.0
     * @return List
     * @date 2019/4/19 15:39
     */
    List<BomUserEntity> getBomUserListByBomId(String corpid, Long bomId);

    void insertBatch(List<BomUserEntity> bomUserEntityList, boolean isImport) throws XbbException;

    void batchUpdateByUserIdIn(String corpid, List<Long> dataIdIn, List<UserTeamEntity> teamEntityList, Integer isMain, Integer del) throws XbbException;

    void batchUpdateByUserIdIn(String corpid, List<Long> dataIdIn, List<UserTeamEntity> teamEntityList, Integer isMain, Integer del, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    /**
     * 批量剔除团队
     * @param corpid
     * @param removeIdList 客户团队表idList
     */
    Map<Long, String> batchDeleteById(String corpid, List<Long> removeIdList) throws XbbException;

    /**
     * 批量剔除团队
     * @param bomUserEntityList
     * @param corpid
     * @param del
     * @return
     * @throws XbbException
     */
    Integer deleteBatchUser(List<BomUserEntity> bomUserEntityList, String corpid, Integer del) throws XbbException;

    /**
     * 批量更新
     * @param list
     * @param corpid
     * @return
     * @throws XbbException
     */
    Integer updateBatch(List<BomUserEntity> list, String corpid) throws XbbException;

    /**
     * 更新协同人可编辑权限
     *
     * @param bomUserEntity
     */
    void updateEditFormPer(BomUserEntity bomUserEntity) throws XbbException;

    /**
     * 编辑团队成员标签
     *
     * @param bomUserEntity
     */
    void editLabel(BomUserEntity bomUserEntity) throws XbbException ;

    void batchUpdateCoAndPerByUserIdIn(String corpid, List<Long> idIn, List<UserTeamEntity> teamEntityList, Integer isMain, boolean needThrow, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    /**
     * 更新团队协同人信息和协同人可编辑权限
     *
     * @param corpid
     * @param idIn
     * @param updateUserToCoTeamList
     * @param coopUser
     * @param needThrow
     */
    void batchUpdateCoAndPerByUserIdIn(String corpid, List<Long> idIn, List<UserTeamEntity> updateUserToCoTeamList, Integer coopUser, boolean needThrow) throws XbbException;


}
